package com.hspedu.writer_;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.Buffer;

/**
 * @author DL5O
 * @version 1.0
 * 演示BufferedWriter的使用
 */
public class BufferedWriter_ {
    public static void main(String[] args) throws IOException {
        //D:\ok.txt
        String filePath = "D:\\ok.txt";
        //创建BufferedWriter
        //1.new FileWriter(filePath,true) 表示以追加的方式进行创建
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath,true));
        bufferedWriter.write("hello,world!");
        bufferedWriter.newLine();//插入一个和系统相关的换行符
        bufferedWriter.write("hello,world!");
        bufferedWriter.newLine();//插入一个和系统相关的换行符
        //关闭外层流即可，传入的FileWriter 会自动关闭
        bufferedWriter.close();
    }
}
